/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package forge

import (
	"github.com/rs/zerolog/log"
	"github.com/spf13/cobra"
	"satellite/app/forge"
)

// offlineCmd represents the offlineCmd command
var offlineCmd = &cobra.Command{
	Use:     "offline",
	Aliases: []string{`/o`},
	Short:   "将成员从 GR 离线",
	Long:    `将成员从 GR 离线, 可选择是否强制离线, 强制离线将立即删除指定pod.`,
	Args:    Args,
	Run: func(cmd *cobra.Command, args []string) {
		runner := forge.NewOffline(offlineOption).WithBase(base)
		err := runner.Run()
		if err != nil {
			log.Warn().Err(err).Send()
			return
		}
	},
}

var (
	offlineOption = new(forge.OfflineOption)
)

func init() {
	forgeCmd.AddCommand(offlineCmd)
	offlineCmd.Flags().BoolVarP(&offlineOption.SelectAll, "all", "a", false, "选择所有成员")
	offlineCmd.Flags().BoolVarP(&offlineOption.SelectPrimary, "primary", "p", false, "选择主要成员")
	offlineCmd.Flags().BoolVarP(&offlineOption.SelectSecondary, "secondary", "s", false, "选择次要成员")
	offlineCmd.Flags().BoolVarP(&offlineOption.IsForce, "force", "f", false, "强制离组")
	offlineCmd.Flags().IntSliceVarP(&offlineOption.SelectOrdinal, "ordinal", "o", nil, "选择执行序号成员")
}
